<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/favicon.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon.png">
  <link rel="mask-icon" href="/images/favicon.png" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    hostname: new URL('https://codz-me.vercel.app').hostname,
    root: '/',
    scheme: 'Muse',
    version: '7.7.1',
    exturl: false,
    sidebar: {"position":"right","display":"post","padding":18,"offset":12,"onmobile":false},
    copycode: {"enable":false,"show_result":false,"style":null},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    bookmark: {"enable":false,"color":"#222","save":"auto"},
    fancybox: true,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    comments: {"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: '',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}
  };
</script>

  <meta name="description" content="Bug Not Found">
<meta property="og:type" content="website">
<meta property="og:title" content="Code Is Poetry">
<meta property="og:url" content="https://codz-me.vercel.app/page/4/index.html">
<meta property="og:site_name" content="Code Is Poetry">
<meta property="og:description" content="Bug Not Found">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="laudukang">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://codz-me.vercel.app/page/4/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: true,
    isPost: false
  };
</script>

  <title>Code Is Poetry</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Code Is Poetry</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
  </div>

  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
        <li class="menu-item menu-item-commonweal">

    <a href="/404/" rel="section"><i class="fa fa-fw fa-heartbeat"></i>公益 404</a>

  </li>
  </ul>

</nav>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content">
            

  <div class="posts-expand">
        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://codz-me.vercel.app/2015/09/01/google-java-program-special/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/head.png">
      <meta itemprop="name" content="laudukang">
      <meta itemprop="description" content="Bug Not Found">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Code Is Poetry">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2015/09/01/google-java-program-special/" class="post-title-link" itemprop="url">Google Java编程风格指南</a>
        </h1>

        <div class="post-meta">
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2015-09-01 17:27:28 17:27:28" itemprop="dateModified" datetime="2015-09-01T17:27:28+08:00">2015-09-01 17:27:28</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index">
                    <span itemprop="name">Java</span>
                  </a>
                </span>
            </span>

          
            <span id="/2015/09/01/google-java-program-special/" class="post-meta-item leancloud_visitors" data-flag-title="Google Java编程风格指南" title="阅读次数">
                <span hidden class="leancloud-visitors-count"></span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>请参考</p>
<ul>
<li><a href="http://hawstein.com/posts/google-java-style.html" target="_blank" rel="noopener">Google Java编程风格指南</a></li>
<li><a href="https://github.com/zh-google-styleguide/zh-google-styleguide" target="_blank" rel="noopener">zh-google-styleguide</a></li>
<li><a href="https://github.com/google/google-java-format" target="_blank" rel="noopener">google-java-format</a></li>
<li><a href="http://zh-google-styleguide.readthedocs.io/en/latest/google-cpp-styleguide/" target="_blank" rel="noopener">Google 开源项目风格指南</a></li>
</ul>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://codz-me.vercel.app/2015/08/23/java-null-object-call-static-method/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/head.png">
      <meta itemprop="name" content="laudukang">
      <meta itemprop="description" content="Bug Not Found">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Code Is Poetry">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2015/08/23/java-null-object-call-static-method/" class="post-title-link" itemprop="url">Java null object 能否调用 static 方法</a>
        </h1>

        <div class="post-meta">
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2015-08-23 23:19:19 23:19:19" itemprop="dateModified" datetime="2015-08-23T23:19:19+08:00">2015-08-23 23:19:19</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index">
                    <span itemprop="name">Java</span>
                  </a>
                </span>
            </span>

          
            <span id="/2015/08/23/java-null-object-call-static-method/" class="post-meta-item leancloud_visitors" data-flag-title="Java null object 能否调用 static 方法" title="阅读次数">
                <span hidden class="leancloud-visitors-count"></span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>The following code contains an example, in which a static method is called via a null reference.</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Test</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String... args)</span> </span>&#123;</span><br><span class="line">        Test test = <span class="keyword">null</span>;</span><br><span class="line">        test.greeting(); <span class="comment">// call with null reference</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">greeting</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        System.out.println(<span class="string">"Hello World"</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>Because Test::greeting is a static method, the expression test.greeting() is identical to Test.greeting().</p>
<p>For that reason, there is no NullPointerException thrown at runtime.</p>
<p>reference:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/24800309/can-we-call-a-static-method-with-a-null-object-in-java-if-so-how" target="_blank" rel="noopener">Can we call a static method with a null object in Java? If so, how?</a></li>
<li><a href="https://stackoverflow.com/questions/3293353/how-come-invoking-a-static-method-on-a-null-reference-doesnt-throw-nullpointe" target="_blank" rel="noopener">How come invoking a (static) method on a null reference doesn’t throw NullPointerException?</a></li>
</ul>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://codz-me.vercel.app/2015/08/17/translation-of-java-arraylist-vector/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/head.png">
      <meta itemprop="name" content="laudukang">
      <meta itemprop="description" content="Bug Not Found">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Code Is Poetry">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2015/08/17/translation-of-java-arraylist-vector/" class="post-title-link" itemprop="url">[译]Java ArrayList 与 Vector</a>
        </h1>

        <div class="post-meta">
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2015-08-17 23:54:08 23:54:08" itemprop="dateModified" datetime="2015-08-17T23:54:08+08:00">2015-08-17 23:54:08</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index">
                    <span itemprop="name">Java</span>
                  </a>
                </span>
            </span>

          
            <span id="/2015/08/17/translation-of-java-arraylist-vector/" class="post-meta-item leancloud_visitors" data-flag-title="[译]Java ArrayList 与 Vector" title="阅读次数">
                <span hidden class="leancloud-visitors-count"></span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="线程同步与线程安全"><a href="#线程同步与线程安全" class="headerlink" title="线程同步与线程安全"></a>线程同步与线程安全</h2><p>Vector 是线程同步的，而ArrayList不是；</p>
<p>线程同步和线程安全意味着同一时间只允许一个线程访问数据；</p>
<p>Vector 类中的所有方法都是线程同步的，这就解析了为什么创建Vector 对象时就属于线程同步的了。</p>
<h2 id="性能对比"><a href="#性能对比" class="headerlink" title="性能对比"></a>性能对比</h2><p>就两者相比较，Vector 属于线程同步的，其性能相对低，而ArrayList 相对较快，因为ArrayList 允许两个或多个线程同时访问数据，而Vector 则限制同一时间只允许一个线程访问数据。</p>
<h2 id="自动增长容量"><a href="#自动增长容量" class="headerlink" title="自动增长容量"></a>自动增长容量</h2><p>Vector 默认按当前大小的两倍增长，而ArrayList 是按50%长度增长，当你往Arraylist 中插入元素（当填满元素）</p>
<p>Arraylist 的默认大小为10，Arraylist 会检查是否到了最后一个元素，然后会创建新的数组，复制原数组的数据到新数组，原数组由jvm回收。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//ArrayList源码</span></span><br><span class="line"> <span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Default initial capacity.</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> DEFAULT_CAPACITY = <span class="number">10</span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">//Vector源码</span></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Constructs an empty vector so that its internal data array</span></span><br><span class="line"><span class="comment"> * has size &#123;<span class="doctag">@code</span> 10&#125; and its standard capacity increment is</span></span><br><span class="line"><span class="comment"> * zero.</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="title">Vector</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    <span class="keyword">this</span>(<span class="number">10</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="设定增长大小"><a href="#设定增长大小" class="headerlink" title="设定增长大小"></a>设定增长大小</h3><p>ArrayList 不能指定增长长度，而Vector 可以指定增长长度，你可以通过Vector 类的下面方法指定增长长度</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> <span class="title">setSize</span><span class="params">(<span class="keyword">int</span> i)</span> </span>&#123;</span><br><span class="line"><span class="comment">//some code</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//来自源码</span></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Sets the size of this vector. If the new size is greater than the</span></span><br><span class="line"><span class="comment"> * current size, new &#123;<span class="doctag">@code</span> null&#125; items are added to the end of</span></span><br><span class="line"><span class="comment"> * the vector. If the new size is less than the current size, all</span></span><br><span class="line"><span class="comment"> * components at index &#123;<span class="doctag">@code</span> newSize&#125; and greater are discarded.</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span>  newSize   the new size of this vector</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@throws</span> ArrayIndexOutOfBoundsException if the new size is negative</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> <span class="title">setSize</span><span class="params">(<span class="keyword">int</span> newSize)</span> </span>&#123;</span><br><span class="line">    modCount++;</span><br><span class="line">    <span class="keyword">if</span> (newSize &gt; elementCount) &#123;</span><br><span class="line">        ensureCapacityHelper(newSize);</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i = newSize ; i &lt; elementCount ; i++) &#123;</span><br><span class="line">            elementData[i] = <span class="keyword">null</span>;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    elementCount = newSize;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="枚举"><a href="#枚举" class="headerlink" title="枚举"></a>枚举</h2><p>除了HashTable，Vector 是同时使用了枚举和迭代的唯一一个类，而ArrayList 只能用迭代器遍历一个ArrayList 对象。</p>
<h2 id="官方定义"><a href="#官方定义" class="headerlink" title="官方定义"></a>官方定义</h2><p><code>java.util.Vector</code>自jdk1.0就出现了，<code>java.util.ArrayList</code>在jdk1.2中被作为Java 集合框架介绍过；在jdk1.2版本，Vector 类已经被重构实现List 接口。</p>
<p>reference:</p>
<ul>
<li><a href="http://jeet-software.blogspot.in/2014/11/arraylist-vs-vector-in-java.html" target="_blank" rel="noopener">Arraylist vs Vector in Java</a></li>
<li><a href="http://www.javacodegeeks.com/2010/08/java-best-practices-vector-arraylist.html" target="_blank" rel="noopener">Java Best Practices – Vector vs ArrayList vs HashSet</a></li>
</ul>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://codz-me.vercel.app/2015/08/17/some-blogs-of-technology/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/head.png">
      <meta itemprop="name" content="laudukang">
      <meta itemprop="description" content="Bug Not Found">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Code Is Poetry">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2015/08/17/some-blogs-of-technology/" class="post-title-link" itemprop="url">Some blogs of technology</a>
        </h1>

        <div class="post-meta">
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2015-08-30 21:19:14 21:19:14" itemprop="dateModified" datetime="2015-08-30T21:19:14+08:00">2015-08-30 21:19:14</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index">
                    <span itemprop="name">Java</span>
                  </a>
                </span>
            </span>

          
            <span id="/2015/08/17/some-blogs-of-technology/" class="post-meta-item leancloud_visitors" data-flag-title="Some blogs of technology" title="阅读次数">
                <span hidden class="leancloud-visitors-count"></span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <ul>
<li><a href="http://blog.devtang.com/" target="_blank" rel="noopener">JMS、JNI、compass、JFX、缓存技术、大数据存储 唐巧，IOS程序员</a></li>
<li><a href="http://blog.s135.com/" target="_blank" rel="noopener">张宴</a></li>
<li><a href="http://tianchunbinghe.blog.163.com/" target="_blank" rel="noopener">春田冰河，人称伞哥，独特的个性以及高度自信的人，LISP语言鼻祖了</a></li>
<li><a href="http://www.lanceyan.com/" target="_blank" rel="noopener">lanceyan 严澜，大数据，算法，敏捷，架构无所不</a></li>
<li><a href="http://www.chengxuyuans.com/program_life/62920.html" target="_blank" rel="noopener">从程序员到CTO的Java技术路线图</a></li>
</ul>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://codz-me.vercel.app/2015/08/13/java-programmer-advanced-learning-day-3/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/head.png">
      <meta itemprop="name" content="laudukang">
      <meta itemprop="description" content="Bug Not Found">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Code Is Poetry">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2015/08/13/java-programmer-advanced-learning-day-3/" class="post-title-link" itemprop="url">[Day 3] Java 程序员修炼之道学习笔记</a>
        </h1>

        <div class="post-meta">
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2015-08-13 11:13:51 11:13:51" itemprop="dateModified" datetime="2015-08-13T11:13:51+08:00">2015-08-13 11:13:51</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index">
                    <span itemprop="name">Java</span>
                  </a>
                </span>
            </span>

          
            <span id="/2015/08/13/java-programmer-advanced-learning-day-3/" class="post-meta-item leancloud_visitors" data-flag-title="[Day 3] Java 程序员修炼之道学习笔记" title="阅读次数">
                <span hidden class="leancloud-visitors-count"></span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <ol>
<li><p><code>@Inject</code>注解</p>
<p><code>@Inject</code>注解可以出现在三种类成员之前：构造器、方法、属性</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//构造器，不含参数的构造器也可以使用@Inject 注解</span></span><br><span class="line"><span class="meta">@Inject</span> <span class="function"><span class="keyword">public</span> <span class="title">MurmurMessage</span><span class="params">(Header header, Content content)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.header = header;</span><br><span class="line">    <span class="keyword">this</span>.content = content;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//方法</span></span><br><span class="line"><span class="meta">@Inject</span> <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setContent</span><span class="params">(Content content)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.content = content;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//属性</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">MurmurMessenger</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    <span class="meta">@Inject</span> <span class="keyword">private</span> MurmurMessage murmurMessage;</span><br><span class="line">    <span class="comment">//...</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p><code>@Qualifier</code>注解</p>
<p>用<code>@Qualifier</code>注解区分同一类型MusicGenre的不用bean</p>
<p>必须标记为<code>@Qualifier</code>和<code>@Retention(RUNTIME)</code>，以确保该限定注解运行时一直有效</p>
<p>通常还会加上<code>@Documented</code>注解，从而该实现就能加API的公共Javadoc中</p>
<p>可以有属性</p>
<p><code>@Target</code>注解可以限定其使用范围</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Documented</span></span><br><span class="line"><span class="meta">@Retention</span>(RUNTIME)</span><br><span class="line"><span class="meta">@Qualifier</span></span><br><span class="line"><span class="keyword">public</span> <span class="meta">@interface</span> MusicGenre</span><br><span class="line">&#123;</span><br><span class="line">    <span class="function">Genre <span class="title">genre</span><span class="params">()</span> <span class="keyword">default</span> Genre.TRANCE</span>;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">enum</span> GENRE &#123; CLASSICAL, METAL, ROCK, TRANCE &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">MetalRecordAlbumns</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    <span class="meta">@Inject</span> <span class="meta">@MusicGenre</span>(GENRE.METAL) Genre genre;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p><code>@Named</code>注解</p>
<p>将<code>@Named</code>和<code>@Inject</code>一起使用，符合指定名称并且类型正确的对象会被注入</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//注入了名称为“murmur”和“broadcast”的两个MurmurMessage对象</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">MurmurMessenger</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    <span class="meta">@Inject</span> <span class="meta">@Named</span>(<span class="string">"murmur"</span>) <span class="keyword">private</span> MurmurMessage murmurMessage;</span><br><span class="line">    <span class="meta">@Inject</span> <span class="meta">@Named</span>(<span class="string">"broadcast"</span>) <span class="keyword">private</span> MurmurMessage broadcastMessage;</span><br><span class="line">    <span class="comment">//...</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p><code>@Singleton</code>注解</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//单例模式</span></span><br><span class="line"><span class="keyword">public</span> MurmurMessage</span><br><span class="line">&#123;</span><br><span class="line">    <span class="meta">@Inject</span> <span class="meta">@Singleton</span> MessageHeader defaultHeader;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>接口Provider<T></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> com.google.inject.Inject;</span><br><span class="line"><span class="keyword">import</span> com.google.inject.Provider;</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">MurmurMessage</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">  <span class="meta">@Inject</span> MurmurMessage (Provider&lt;Message&gt; messageProvider)</span><br><span class="line">  &#123;</span><br><span class="line">      Message msg1 = messageProvider.get();</span><br><span class="line">      <span class="keyword">if</span> (someGlobalCondition)</span><br><span class="line">      &#123;</span><br><span class="line">          Message copyOfMsg1 = messageProvider.get();</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="comment">//...</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p><a href="http://blog.chinaunix.net/uid-20749563-id-718418.html" target="_blank" rel="noopener">Google Guice使用入门</a></p>
</li>
<li><p><a href="https://github.com/google/guice/wiki/Motivation" target="_blank" rel="noopener">Github google/guice wiki</a></p>
</li>
</ol>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://codz-me.vercel.app/2015/08/11/java-programmer-advanced-learning-day-2/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/head.png">
      <meta itemprop="name" content="laudukang">
      <meta itemprop="description" content="Bug Not Found">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Code Is Poetry">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2015/08/11/java-programmer-advanced-learning-day-2/" class="post-title-link" itemprop="url">[Day 2] Java 程序员修炼之道学习笔记</a>
        </h1>

        <div class="post-meta">
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2015-08-11 23:54:06 23:54:06" itemprop="dateModified" datetime="2015-08-11T23:54:06+08:00">2015-08-11 23:54:06</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index">
                    <span itemprop="name">Java</span>
                  </a>
                </span>
            </span>

          
            <span id="/2015/08/11/java-programmer-advanced-learning-day-2/" class="post-meta-item leancloud_visitors" data-flag-title="[Day 2] Java 程序员修炼之道学习笔记" title="阅读次数">
                <span hidden class="leancloud-visitors-count"></span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <ol>
<li><p>异步I/O操作</p>
<ul>
<li><p>异步I/O-将来式</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">try</span> &#123;</span><br><span class="line">        Path file = Paths.get(<span class="string">"/usr/karianna/foobar.txt"</span>);</span><br><span class="line">        <span class="comment">//异步打开文件</span></span><br><span class="line">        AsynchronousFileChannel channel = AsynchronousFileChannel</span><br><span class="line">                .open(file);</span><br><span class="line"></span><br><span class="line">        ByteBuffer buffer = ByteBuffer.allocate(<span class="number">100_000</span>);</span><br><span class="line">        Future&lt;Integer&gt; result = channel.read(buffer, <span class="number">0</span>);</span><br><span class="line">        <span class="comment">//判断result是否结束</span></span><br><span class="line">        <span class="keyword">while</span> (!result.isDone()) &#123;</span><br><span class="line">            ProfitCalculator.calculateTax();</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        Integer bytesRead = result.get();</span><br><span class="line">        System.out.println(<span class="string">"Bytes read ["</span> + bytesRead + <span class="string">"]"</span>);</span><br><span class="line">    &#125; <span class="keyword">catch</span> (IOException | ExecutionException | InterruptedException e) &#123;</span><br><span class="line">        System.out.println(e.getMessage());</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">private</span> <span class="keyword">static</span> <span class="class"><span class="keyword">class</span> <span class="title">ProfitCalculator</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="title">ProfitCalculator</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">calculateTax</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>异步I/O-回调式</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">try</span> &#123;</span><br><span class="line">        Path file = Paths.get(<span class="string">"/usr/karianna/foobar.txt"</span>);</span><br><span class="line">        AsynchronousFileChannel channel = AsynchronousFileChannel</span><br><span class="line">                .open(file);</span><br><span class="line"></span><br><span class="line">        ByteBuffer buffer = ByteBuffer.allocate(<span class="number">100_000</span>);</span><br><span class="line"></span><br><span class="line">        channel.read(buffer, <span class="number">0</span>, buffer,</span><br><span class="line">                <span class="keyword">new</span> CompletionHandler&lt;Integer, ByteBuffer&gt;() &#123;</span><br><span class="line"></span><br><span class="line">                    <span class="meta">@Override</span></span><br><span class="line">                    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">completed</span><span class="params">(Integer result,</span></span></span><br><span class="line"><span class="function"><span class="params">                            ByteBuffer attachment)</span> </span>&#123;</span><br><span class="line">                        System.out.println(<span class="string">"Bytes read ["</span> + result + <span class="string">"]"</span>);</span><br><span class="line">                    &#125;</span><br><span class="line"></span><br><span class="line">                    <span class="meta">@Override</span></span><br><span class="line">                    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">failed</span><span class="params">(Throwable exception,</span></span></span><br><span class="line"><span class="function"><span class="params">                            ByteBuffer attachment)</span> </span>&#123;</span><br><span class="line">                        System.out.println(exception.getMessage());</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;);</span><br><span class="line">    &#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">        System.out.println(e.getMessage());</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
</li>
<li><p>NetworkChannel<br>获取当前主机networkinterface列表</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            Enumeration&lt;NetworkInterface&gt; interfaceList = NetworkInterface</span><br><span class="line">                    .getNetworkInterfaces();</span><br><span class="line">            <span class="keyword">if</span> (<span class="keyword">null</span> == interfaceList) &#123;</span><br><span class="line">                System.out.println(<span class="string">"--No intercaces found--"</span>);</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                <span class="keyword">while</span> (interfaceList.hasMoreElements()) &#123;</span><br><span class="line">                    NetworkInterface iface = interfaceList.nextElement();</span><br><span class="line">                    System.out.println(<span class="string">"Interface "</span> + iface.getName() + <span class="string">":"</span>);</span><br><span class="line">                    Enumeration&lt;InetAddress&gt; addrList = iface</span><br><span class="line">                            .getInetAddresses();</span><br><span class="line">                    <span class="keyword">if</span> (!addrList.hasMoreElements()) &#123;</span><br><span class="line">                        System.out</span><br><span class="line">                                .println(<span class="string">"\t(No addresses for this interface)"</span>);</span><br><span class="line">                    &#125;</span><br><span class="line">                    <span class="keyword">while</span> (addrList.hasMoreElements()) &#123;</span><br><span class="line">                        InetAddress address = addrList.nextElement();</span><br><span class="line">                        System.out</span><br><span class="line">                                .print(<span class="string">"\tAddress "</span></span><br><span class="line">                                        + ((address <span class="keyword">instanceof</span> Inet4Address ? <span class="string">"(v4)"</span></span><br><span class="line">                                                : (address <span class="keyword">instanceof</span> Inet6Address ? <span class="string">"(v6)"</span></span><br><span class="line">                                                        : <span class="string">"(?)"</span>))));</span><br><span class="line">                        System.out.println(<span class="string">": "</span> + address.getHostAddress());</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125; <span class="keyword">catch</span> (SocketException se) &#123;</span><br><span class="line">            System.out.println(<span class="string">"Error getting network interfaces:"</span></span><br><span class="line">                    + se.getMessage());</span><br><span class="line">        &#125;</span><br><span class="line">   &#125;</span><br></pre></td></tr></table></figure>
</li>
</ol>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://codz-me.vercel.app/2015/08/11/java-programmer-advanced-learning-day-1/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/head.png">
      <meta itemprop="name" content="laudukang">
      <meta itemprop="description" content="Bug Not Found">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Code Is Poetry">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2015/08/11/java-programmer-advanced-learning-day-1/" class="post-title-link" itemprop="url">[Day 1] Java 程序员修炼之道学习笔记</a>
        </h1>

        <div class="post-meta">
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2015-08-11 13:02:49 13:02:49" itemprop="dateModified" datetime="2015-08-11T13:02:49+08:00">2015-08-11 13:02:49</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index">
                    <span itemprop="name">Java</span>
                  </a>
                </span>
            </span>

          
            <span id="/2015/08/11/java-programmer-advanced-learning-day-1/" class="post-meta-item leancloud_visitors" data-flag-title="[Day 1] Java 程序员修炼之道学习笔记" title="阅读次数">
                <span hidden class="leancloud-visitors-count"></span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <ol>
<li><p>二进制文本<br>让 int x 用位模式表示十进制值102</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//Java 7 之前的写法：</span></span><br><span class="line"><span class="keyword">int</span> x = Integer.parseInt(<span class="string">"1100110"</span>,<span class="number">2</span>);</span><br><span class="line"><span class="comment">//Java 7 的写法：</span></span><br><span class="line"><span class="keyword">int</span> x = <span class="number">0b1100110</span>;</span><br></pre></td></tr></table></figure></li>
<li><p>数字中的下划线</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">long</span> tmp=<span class="number">1_000_000</span>;</span><br></pre></td></tr></table></figure></li>
<li><p>final重抛</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">try</span> &#123;</span><br><span class="line">doSomethingWhichMightThrowIOException();</span><br><span class="line">doSomethingElseWhichMightThrowSQLException();</span><br><span class="line">&#125; <span class="keyword">catch</span> (<span class="keyword">final</span> Exception e) &#123;</span><br><span class="line">...</span><br><span class="line"><span class="keyword">throw</span> e;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></li>
<li><p>Try-with-resources (TWR)</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">try</span> (OutputStream out = <span class="keyword">new</span> FileOutputStream(file);</span><br><span class="line">    InputStream is = url.openStream() ) &#123;</span><br><span class="line">        <span class="keyword">byte</span>[] buf = <span class="keyword">new</span> <span class="keyword">byte</span>[<span class="number">4096</span>];</span><br><span class="line">        <span class="keyword">int</span> len;</span><br><span class="line">        <span class="keyword">while</span> ((len = is.read(buf)) &gt; <span class="number">0</span>) &#123;</span><br><span class="line">            out.write(buf, <span class="number">0</span>, len);</span><br><span class="line">        &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></li>
<li><p>Java 7钻石语法</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//不用钻石语法</span></span><br><span class="line">Map&lt;Integer, Map&lt;String, String&gt;&gt; usersLists =<span class="keyword">new</span> HashMap&lt;Integer, Map&lt;String, String&gt;&gt;();</span><br><span class="line"><span class="comment">//使用钻石语法，上面语句少了j近一半字符</span></span><br><span class="line">Map&lt;Integer, Map&lt;String, String&gt;&gt; usersLists = <span class="keyword">new</span> HashMap&lt;&gt;();</span><br></pre></td></tr></table></figure></li>
<li><p>Java 7处理符号链接</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">java.nio.file.Path path = java.nio.file.Paths.get(<span class="string">"/ftp/upload/1.jpg"</span>);</span><br><span class="line">java.nio.file.Path path2 = java.nio.file.Paths.get(<span class="string">"/ftp/upload/2.jpg"</span>).toRealPath();</span><br><span class="line">System.out.println(path.toRealPath());</span><br><span class="line">System.out.println(path2.toString());</span><br></pre></td></tr></table></figure>
<p>其中：</p>
<figure class="highlight angelscript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">-rwxrwxrwx <span class="number">1</span> lau  lau  <span class="number">191221</span>  <span class="number">8</span>月 <span class="number">16</span>  <span class="number">2014</span> <span class="number">1.</span>jpg*</span><br><span class="line">lrwxrwxrwx <span class="number">1</span> root root     <span class="number">17</span>  <span class="number">8</span>月 <span class="number">11</span> <span class="number">12</span>:<span class="number">23</span> <span class="number">2.</span>jpg -&gt; /ftp/upload/<span class="number">1.</span>jpg*</span><br></pre></td></tr></table></figure>
<p>输出：</p>
<figure class="highlight angelscript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">/ftp/upload/<span class="number">1.</span>jpg</span><br><span class="line">/ftp/upload/<span class="number">1.</span>jpg</span><br></pre></td></tr></table></figure></li>
<li><p>Java 7在目录中查找文件</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// Java 7在目录中查找文件</span></span><br><span class="line">java.nio.file.Path path = java.nio.file.Paths</span><br><span class="line">    .get(<span class="string">"F:\\Pictures\\WeixinPictures"</span>);</span><br><span class="line"> <span class="keyword">try</span> (java.nio.file.DirectoryStream&lt;java.nio.file.Path&gt; stream =</span><br><span class="line">        java.nio.file.Files.newDirectoryStream(path, <span class="string">"*jpg"</span>)) &#123;</span><br><span class="line">            <span class="keyword">for</span> (java.nio.file.Path path2 : stream) &#123;</span><br><span class="line">                System.out.println(path2.getFileName());</span><br><span class="line"></span><br><span class="line">              &#125;</span><br><span class="line">    &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">            System.out.println(e.getMessage());</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure></li>
<li><p>Java 7遍历目录树</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// Java 7遍历目录树</span></span><br><span class="line">java.nio.file.Path startingDir = java.nio.file.Paths.get(<span class="string">"F:\\Pictures"</span>);</span><br><span class="line"></span><br><span class="line">  <span class="keyword">try</span> &#123;</span><br><span class="line">      java.nio.file.Files.walkFileTree(startingDir, <span class="keyword">new</span> FindJPGVisitor());</span><br><span class="line">  &#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">      System.out.println(e.getMessage());</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure></li>
<li><p>NIO.2的文件系统I/O</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//创建文件</span></span><br><span class="line">Path target = Paths.get(<span class="string">"D:\\Backup\\MyStuff.txt"</span>);</span><br><span class="line">Path file = Files.createFile(target);</span><br><span class="line"></span><br><span class="line"><span class="comment">//创建文件，带权限</span></span><br><span class="line">Path target = Paths.get(<span class="string">"D:\\Backup\\MyStuff.txt"</span>);</span><br><span class="line">Set&lt;PosixFilePermission&gt; perms =</span><br><span class="line">PosixFilePermissions.fromString(<span class="string">"rw-rw-rw-"</span>);</span><br><span class="line">FileAttribute&lt;Set&lt;PosixFilePermission&gt;&gt; attr =</span><br><span class="line">PosixFilePermissions.asFileAttribute(perms);</span><br><span class="line">Files.createFile(target, attr);</span><br><span class="line"></span><br><span class="line"><span class="comment">//复制文件</span></span><br><span class="line">Path source = Paths.get(<span class="string">"C:\\My Documents\\Stuff.txt"</span>);</span><br><span class="line">Path target = Paths.get(<span class="string">"D:\\Backup\\MyStuff.txt"</span>);</span><br><span class="line">Files.copy(source, target);</span><br><span class="line"></span><br><span class="line"><span class="comment">//删除文件</span></span><br><span class="line">Path target = Paths.get(<span class="string">"D:\\Backup\\MyStuff.txt"</span>);</span><br><span class="line">Files.delete(target);</span><br><span class="line"></span><br><span class="line"><span class="comment">//符号链接</span></span><br><span class="line">Path file = Paths.get(<span class="string">"/ftp/upload/2.jpg"</span>);</span><br><span class="line"><span class="keyword">try</span>&#123;</span><br><span class="line">    <span class="keyword">if</span>(Files.isSymbolicLink(file))&#123;</span><br><span class="line">        file = Files.readSymbolicLink(file);</span><br><span class="line">    &#125;</span><br><span class="line">    Files.readAttributes(file, BasicFileAttributes<span class="class">.<span class="keyword">class</span>)</span>;</span><br><span class="line">    &#125;</span><br><span class="line"><span class="keyword">catch</span> (IOException e)&#123;</span><br><span class="line">    System.out.println(e.getMessage());</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//打开文件，注意编码</span></span><br><span class="line">Path logFile = Paths.get(<span class="string">"/tmp/app.log"</span>);</span><br><span class="line"><span class="keyword">try</span> (BufferedReader reader =</span><br><span class="line">Files.newBufferedReader(logFile, StandardCharsets.UTF_8)) &#123;</span><br><span class="line">String line;</span><br><span class="line"><span class="keyword">while</span> ((line = reader.readLine()) != <span class="keyword">null</span>) &#123;</span><br><span class="line"><span class="comment">//...</span></span><br><span class="line">&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//写入文件</span></span><br><span class="line">Path logFile = Paths.get(<span class="string">"/tmp/app.log"</span>);</span><br><span class="line"><span class="keyword">try</span> (BufferedWriter writer =</span><br><span class="line">Files.newBufferedWrite(logFile, StandardCharsets.UTF_8,</span><br><span class="line">StandardOpenOption.WRITE)) &#123;</span><br><span class="line">writer.write(<span class="string">"Hello World!"</span>);</span><br><span class="line"><span class="comment">//...</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//简化读取和写入，没必要再用while循环把数据从字节数组读到缓冲区里</span></span><br><span class="line">Path logFile = Paths.get(<span class="string">"/tmp/app.log"</span>);</span><br><span class="line">List&lt;String&gt; lines = Files.readAllLines(logFile, StandardCharsets.UTF_8);</span><br><span class="line"><span class="keyword">byte</span>[] bytes = Files.readAllBytes(logFile);</span><br></pre></td></tr></table></figure>
</li>
</ol>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://codz-me.vercel.app/2015/08/10/sublime-text-plugins/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/head.png">
      <meta itemprop="name" content="laudukang">
      <meta itemprop="description" content="Bug Not Found">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Code Is Poetry">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2015/08/10/sublime-text-plugins/" class="post-title-link" itemprop="url">Sublime Text Plugins</a>
        </h1>

        <div class="post-meta">
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2015-08-14 16:57:39 16:57:39" itemprop="dateModified" datetime="2015-08-14T16:57:39+08:00">2015-08-14 16:57:39</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Web/" itemprop="url" rel="index">
                    <span itemprop="name">Web</span>
                  </a>
                </span>
            </span>

          
            <span id="/2015/08/10/sublime-text-plugins/" class="post-meta-item leancloud_visitors" data-flag-title="Sublime Text Plugins" title="阅读次数">
                <span hidden class="leancloud-visitors-count"></span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="MarkdownEditing"><a href="#MarkdownEditing" class="headerlink" title="MarkdownEditing"></a><a href="https://github.com/SublimeText-Markdown/MarkdownEditing" target="_blank" rel="noopener">MarkdownEditing</a></h2><p>Markdown plugin for Sublime Text.</p>
<p>Provides a decent Markdown color scheme (light and dark) with more robust syntax highlighting and useful Markdown editing features for Sublime Text.</p>
<p>3 flavors are supported: Standard Markdown, GitHub flavored Markdown, MultiMarkdown.</p>
<img src="/2015/08/10/sublime-text-plugins/sublime-text-markdown-editing-plugins.png" alt="MarkdownEditing" title="MarkdownEditing">

<h2 id="Markdown-Preview"><a href="#Markdown-Preview" class="headerlink" title="Markdown Preview"></a><a href="https://github.com/revolunet/sublimetext-markdown-preview" target="_blank" rel="noopener">Markdown Preview</a></h2><p>Preview and build your markdown files quickly in your web browser from sublime text 2/3.</p>
<p>You can use builtin [python-markdown][10] parser or use the [github markdown API][5] for the conversion.</p>
<p><strong>NOTE:</strong> If you choose the GitHub API for conversion (set parser: github in your settings), your code will be sent through https to github for live conversion. You’ll have [Github flavored markdown][6], syntax highlighting and EMOJI support for free :heart: :octocat: :gift:. If you make more than 60 calls a day, be sure to set your GitHub API key in the settings :). You can also get most of this in the default Markdown parser with by enabling certain extensions; see “<a href="#parsing-github-flavored-markdown-">Parsing Github Flavored Markdown</a>“” below for more information.</p>
<p><strong>LINUX users:</strong> If you want to use GitHub API for conversion, you’ll need to have a custom Python install that includes python-ssl as its not built in the Sublime Text 2 Linux package. see [@dusteye comment][8]. If you use a custom window manager, also be sure to set a <code>BROWSER</code> environment variable. see [@PPvG comments][9]</p>
<img src="/2015/08/10/sublime-text-plugins/sublimetext-markdown-preview.gif" alt="sublimetext-markdown-preview" title="sublimetext-markdown-preview">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://codz-me.vercel.app/2015/07/27/music-piao-yao-zhou-xun/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/head.png">
      <meta itemprop="name" content="laudukang">
      <meta itemprop="description" content="Bug Not Found">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Code Is Poetry">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2015/07/27/music-piao-yao-zhou-xun/" class="post-title-link" itemprop="url">飘摇-周迅.mp3</a>
        </h1>

        <div class="post-meta">
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2015-07-27 23:54:01 23:54:01" itemprop="dateModified" datetime="2015-07-27T23:54:01+08:00">2015-07-27 23:54:01</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Life/" itemprop="url" rel="index">
                    <span itemprop="name">Life</span>
                  </a>
                </span>
            </span>

          
            <span id="/2015/07/27/music-piao-yao-zhou-xun/" class="post-meta-item leancloud_visitors" data-flag-title="飘摇-周迅.mp3" title="阅读次数">
                <span hidden class="leancloud-visitors-count"></span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="在线播放"><a href="#在线播放" class="headerlink" title="在线播放"></a>在线播放</h2><div style="width: 320px; display: table; margin: 0 auto;">
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=530 height=86 src="//music.163.com/outchain/player?type=2&id=5272940&auto=0&height=66"></iframe>
</div>

<ul>
<li><p><a href="http://music.163.com/#/song?id=5272940" target="_blank" rel="noopener">飘摇-周迅-网易云音乐</a> #updated 2017-11-24 10:23:16</p>
</li>
<li><p><a href="http://www.kugou.com/song/#hash=E282D76D9B4CB91126BD373C7060F6DF&album_id=541172" target="_blank" rel="noopener">飘摇-周迅-酷狗</a></p>
</li>
<li><p><del><a href="http://t.cn/RzPIO0N" target="_blank" rel="noopener">飘摇-周迅-百度音乐</a></del></p>
</li>
</ul>
<h2 id="歌曲鉴赏（来自-百度百科）"><a href="#歌曲鉴赏（来自-百度百科）" class="headerlink" title="歌曲鉴赏（来自 百度百科）"></a>歌曲鉴赏（来自 <a href="http://baike.baidu.com/link?url=9Kk-YsGDX-OninwLp9XqlmdfekaqnKELfHFA3Ak1tc46nJ-nxLTR_2gpHIJzzz7XU0o6U1WZVcVjOHIlJ49sHSKCK2eycrGfaGe2GSWwYFC" target="_blank" rel="noopener">百度百科</a>）</h2><p>  这首歌曲淡淡地给我们讲述了一对恋人的爱情故事。</p>
<p>  他们双方本没有料到上天会将他们安排在一起。</p>
<p>  只是当爱不知不觉地到来时，他们才意识到。</p>
<p>  爱的到来打乱了男女那平静的心房，他们都不知道该如何对待这一份爱情。</p>
<p>  他们快乐地依偎在一起，正如歌曲中的“我飘呀飘，你摇啊摇”。路边的野草是他们爱情的见证。</p>
<p>  但是，这美好的一切似乎是一场梦，当他们回到现实中来时，却发现爱情有时也会使人烦恼、哀愁，想爱又怕受伤；不爱呢，那颗心又不能平静。</p>
<p>  爱情就这样让人摸不到头脑。</p>
<p>  这对恋人面对爱情的考验时，他们选择了让爱情一次性地痛快燃烧。</p>
<p>  要爱就要爱得快乐，爱得纯真，爱得潇洒，也就是爱要爱得“飘摇”。</p>
<h2 id="歌词"><a href="#歌词" class="headerlink" title="歌词"></a>歌词</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">風停了雲知道</span><br><span class="line">愛走了心自然明了</span><br><span class="line">他來時躲不掉</span><br><span class="line">他走得靜悄悄</span><br><span class="line">你不在我預料</span><br><span class="line">擾亂我平靜的步調</span><br><span class="line">怕愛了找苦惱</span><br><span class="line">怕不愛睡不著</span><br><span class="line">我飄啊飄 你搖啊搖</span><br><span class="line">無根的野草</span><br><span class="line">當夢醒了 天晴了</span><br><span class="line">如何再飄搖</span><br><span class="line">啊 愛多一秒 恨不會少</span><br><span class="line">承諾是煎熬</span><br><span class="line">若不計較 就一次 痛快燃燒</span><br><span class="line">往往愛上一個人就只要在一剎那</span><br><span class="line">就這樣 我深深的</span><br><span class="line">被你的眼神打動</span><br><span class="line">但 我又該如何呢</span><br><span class="line">就讓一切隨緣吧 也但願</span><br><span class="line">你也一樣會珍惜那一剎那</span><br><span class="line">所帶來的一切</span><br><span class="line">你不在我預料</span><br><span class="line">擾亂我平靜的步調</span><br><span class="line">怕愛了找苦惱</span><br><span class="line">怕不愛睡不著</span><br><span class="line">我飄啊飄 你搖啊搖</span><br><span class="line">無根的野草</span><br><span class="line">當夢醒了 天晴了 如何再飄搖</span><br><span class="line">啊 愛多一秒 恨不會少</span><br><span class="line">承諾是煎熬</span><br><span class="line">若不計較 就一次 痛快燃燒</span><br><span class="line">我飄啊飄 你搖啊搖</span><br><span class="line">無根的野草</span><br><span class="line">當夢醒了 天晴了</span><br><span class="line">如何再飄搖</span><br><span class="line">愛多一秒 恨不會少</span><br><span class="line">承諾是煎熬</span><br><span class="line">若不計較 就一次痛快燃燒</span><br><span class="line">若不計較 就一次 痛快燃燒</span><br></pre></td></tr></table></figure>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

        
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://codz-me.vercel.app/2015/07/23/multithreading-in-java/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/head.png">
      <meta itemprop="name" content="laudukang">
      <meta itemprop="description" content="Bug Not Found">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Code Is Poetry">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          
            <a href="/2015/07/23/multithreading-in-java/" class="post-title-link" itemprop="url">[Repost]Multithreading in Java</a>
        </h1>

        <div class="post-meta">
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2015-07-23 15:40:57 15:40:57" itemprop="dateModified" datetime="2015-07-23T15:40:57+08:00">2015-07-23 15:40:57</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index">
                    <span itemprop="name">Java</span>
                  </a>
                </span>
            </span>

          
            <span id="/2015/07/23/multithreading-in-java/" class="post-meta-item leancloud_visitors" data-flag-title="[Repost]Multithreading in Java" title="阅读次数">
                <span hidden class="leancloud-visitors-count"></span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h4 id="Remark-Finished-read-1-7-2015-07-23-15-40-57"><a href="#Remark-Finished-read-1-7-2015-07-23-15-40-57" class="headerlink" title="Remark: Finished read 1-7, 2015-07-23 15:40:57"></a>Remark: Finished read 1-7, 2015-07-23 15:40:57</h4><p>Multithreading in Java is a very important topic. I have written a lot about Threads in Java. Java Thread is a lightweight process that executes some task. Java provides multithreading support with the Thread class and an application can create multiple threads executing concurrently.</p>
<img src="/2015/07/23/multithreading-in-java/multithreading-in-java.jpg" alt="multithreading-in-java.jpg" title="">


<p>There are two types of threads in an application – user thread and daemon thread. When we start an application, main is the first user thread created and we can create multiple user threads as well as daemon threads. When all the user threads are executed, JVM terminates the program.</p>
<p>We can set different priorities to different Threads but it doesn’t guarantee that higher priority thread will execute first than lower priority thread. Thread scheduler is the part of Operating System implementation and when a Thread is started, it’s execution is controlled by Thread Scheduler and JVM doesn’t have any control on it’s execution.</p>
<p>We can create Threads by either implementing Runnable interface or by extending Thread Class.</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">Thread t = <span class="keyword">new</span> Thread(<span class="keyword">new</span> Runnable()&#123;</span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">run</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<p>Above is a one liner statement to create new Thread, Here we are creating Runnable as Anonymous Class, read this post to learn about inner class, nested class and anonymous inner class.</p>
<p>In last few weeks, I have posted some useful articles on multithreading in java, you can follow them in order to learn about Threads in Java.</p>
<h1 id="Threads-in-Java"><a href="#Threads-in-Java" class="headerlink" title="Threads in Java"></a>Threads in Java</h1><img src="/2015/07/23/multithreading-in-java/java-thread.png" alt="java-thread.png" title="">


<p>With Java 8 lambda expressions, we can create Thread in java like below too because Runnable is a functional interface.</p>
<ol>
<li><h3 id="Java-Thread-Example"><a href="#Java-Thread-Example" class="headerlink" title="Java Thread Example"></a><span id="java-thread-example"><a href="https://www.journaldev.com/1016/java-thread-example" target="_blank" rel="noopener">Java Thread Example</a></span></h3><p>This is the first post in the multithreading in java tutorial series. Read this to learn about <strong>Process</strong> and <strong>Thread</strong>. What is the difference between Thread and Process. Benefits of using Threads and how we can create Threads using <strong>Runnable</strong> interface and <strong>Thread</strong> class. This post also compares Runnable interface with Thread class.</p>
</li>
<li><h3 id="Java-Thread-Sleep"><a href="#Java-Thread-Sleep" class="headerlink" title="Java Thread Sleep"></a><span id="java-thread-sleep"><a href="https://www.journaldev.com/1020/thread-sleep-java" target="_blank" rel="noopener">Java Thread Sleep</a></span></h3><p><em>Java Thread sleep</em> is used to pause the execution of current thread. We will use Thread sleep extensively in future posts, so it’s good to know how it works and is it accurate or not?</p>
</li>
<li><h3 id="Java-Thread-Join"><a href="#Java-Thread-Join" class="headerlink" title="Java Thread Join"></a><span id="java-thread-join"><a href="https://www.journaldev.com/1024/java-thread-join-example" target="_blank" rel="noopener">Java Thread Join</a></span></h3><p>Sometimes we need to wait for other threads to finish it’s execution before we can proceed. We can achieve this using <strong>Thread join</strong>, learn how it works and when we should use it.</p>
</li>
<li><h3 id="Java-Thread-States"><a href="#Java-Thread-States" class="headerlink" title="Java Thread States"></a><span id="java-thread-states"><a href="https://www.journaldev.com/1044/thread-life-cycle-in-java-thread-states-in-java" target="_blank" rel="noopener">Java Thread States</a></span></h3><p>Understanding different <strong>states of thread</strong> is important. Learn how thread changes it’s state and how thread scheduler changes thread state.</p>
</li>
<li><h3 id="Java-Thread-wait-notify-and-notifyAll"><a href="#Java-Thread-wait-notify-and-notifyAll" class="headerlink" title="Java Thread wait, notify and notifyAll"></a><span id="java-thread-wait-notify-and-notifyall"><a href="https://www.journaldev.com/1037/java-thread-wait-notify-and-notifyall-example" target="_blank" rel="noopener">Java Thread wait, notify and notifyAll</a></span></h3><p>Java Object class contains three methods using which threads can communicate about the lock status of a resource. Learn with example usage of these Object class methods in a simple Wait-Notify implementation.</p>
</li>
<li><h3 id="Java-Thread-Safety-and-Java-Synchronization"><a href="#Java-Thread-Safety-and-Java-Synchronization" class="headerlink" title="Java Thread Safety and Java Synchronization"></a><span id="java-thread-safety-and-java-synchronization"><a href="https://www.journaldev.com/1061/thread-safety-in-java" target="_blank" rel="noopener" title="Java Synchronization and Thread Safety Tutorial with Examples">Java Thread Safety and Java Synchronization</a></span></h3><p>We know that Threads share Object resources, it can lead to data corruption because these operations are not atomic. Learn how we can achieve <strong><a href="https://www.journaldev.com/1061/thread-safety-in-java" target="_blank" rel="noopener">thread safety in java</a></strong> using different methods. Read this post to learn about the correct usage of <strong>synchronization</strong>, synchronized methods and synchronized blocks.<br>There are various examples of synchronized usage and the post explains what are the issues with them.</p>
</li>
<li><h3 id="Java-Exception-in-thread-main"><a href="#Java-Exception-in-thread-main" class="headerlink" title="Java Exception in thread main"></a><span id="java-exception-in-thread-main"><a href="https://www.journaldev.com/611/exception-in-thread-main-java" target="_blank" rel="noopener">Java Exception in thread main</a></span></h3><p>JVM creates first thread using <strong>main</strong> method. This post explains about some common exceptions we see in daily life and what is the root cause of them and how to fix them.</p>
</li>
<li><h3 id="Thread-Safety-in-Singleton-Class"><a href="#Thread-Safety-in-Singleton-Class" class="headerlink" title="Thread Safety in Singleton Class"></a><span id="thread-safety-in-singleton-class"><a href="https://www.journaldev.com/171/thread-safety-in-java-singleton-classes-with-example-code" target="_blank" rel="noopener">Thread Safety in Singleton Class</a></span></h3><p>In this article, you will learn basic concepts of creating Singleton class. What are thread safety issues with different implementation. How we can achieve <strong>thread safety in Singleton class</strong>.</p>
</li>
<li><h3 id="Daemon-Thread-in-Java"><a href="#Daemon-Thread-in-Java" class="headerlink" title="Daemon Thread in Java"></a><span id="daemon-thread-in-java"><a href="https://www.journaldev.com/1072/daemon-thread-in-java" target="_blank" rel="noopener" title="Daemon Thread in Java">Daemon Thread in Java</a></span></h3><p>A simple article explaining about <strong>daemon threads</strong> and how we can create daemon threads in java.</p>
</li>
<li><h3 id="Java-Thread-Local"><a href="#Java-Thread-Local" class="headerlink" title="Java Thread Local"></a><span id="java-thread-local"><a href="https://www.journaldev.com/1076/java-threadlocal-example" target="_blank" rel="noopener" title="Java ThreadLocal Example to create thread-local variables">Java Thread Local</a></span></h3><p>We know that threads share Object’s variables but what if we want to have thread-local variables created at class level. Java provides <strong>ThreadLocal</strong> utility class to create thread-local variables. Read more to learn about how we can create <em>ThreadLocal</em> variables in java program.</p>
</li>
<li><h3 id="Java-Thread-Dump"><a href="#Java-Thread-Dump" class="headerlink" title="Java Thread Dump"></a><span id="java-thread-dump"><a href="https://www.journaldev.com/1053/java-thread-dump-visualvm-jstack-kill-3-jcmd" target="_blank" rel="noopener" title="How to generate Thread Dump in Java">Java Thread Dump</a></span></h3><p><strong>Java Thread dump</strong> provides the current threads information for the program. Java Thread dump provides useful information to analyze performance issues with the application. You can use thread dump to find and fix deadlock situations. This post explains different methods that can be used to generate thread dump in java.</p>
</li>
<li><h3 id="How-to-Analyze-Deadlock-and-avoid-it-in-Java"><a href="#How-to-Analyze-Deadlock-and-avoid-it-in-Java" class="headerlink" title="How to Analyze Deadlock and avoid it in Java"></a><span id="how-to-analyze-deadlock-and-avoid-it-in-java"><a href="https://www.journaldev.com/1058/deadlock-in-java-example" target="_blank" rel="noopener" title="Java Deadlock Example and How to analyze deadlock situation">How to Analyze Deadlock and avoid it in Java</a></span></h3><p>Deadlock is a situation where multiple threads are waiting for each other to release resources causing cyclic dependency. This article discusses about the situation in which we can get deadlock in a java program. How we can use Thread dump to find the deadlock and best practices to <strong>avoid deadlock in java</strong> program.</p>
</li>
<li><h3 id="Java-Timer-Thread"><a href="#Java-Timer-Thread" class="headerlink" title="Java Timer Thread"></a><span id="java-timer-thread"><a href="https://www.journaldev.com/1050/java-timer-timertask-example" target="_blank" rel="noopener" title="Java Timer TimerTask Example">Java Timer Thread</a></span></h3><p>This post explains how we can use <strong>Java Timer</strong> and TimerTask classes to create jobs to run at scheduled interval, an example program showing it’s usage and how we can cancel the timer.</p>
</li>
<li><h3 id="Java-Producer-Consumer-Problem"><a href="#Java-Producer-Consumer-Problem" class="headerlink" title="Java Producer Consumer Problem"></a><span id="java-producer-consumer-problem"><a href="https://www.journaldev.com/1034/java-blockingqueue-example" target="_blank" rel="noopener" title="Java BlockingQueue Example implementing Producer Consumer Problem">Java Producer Consumer Problem</a></span></h3><p>Before Java 5, producer-consumer problem can be solved using wait() and notify() methods but introduction of BlockingQueue has made it very easy. Learn how we can use BlockingQueue to solve producer consumer problem in java.</p>
</li>
<li><h3 id="Java-Thread-Pool"><a href="#Java-Thread-Pool" class="headerlink" title="Java Thread Pool"></a><span id="java-thread-pool"><a href="https://www.journaldev.com/1069/threadpoolexecutor-java-thread-pool-example-executorservice" target="_blank" rel="noopener" title="Java Thread Pool Example using Executors and ThreadPoolExecutor">Java Thread Pool</a></span></h3><p>Java Thread Pool is a collection of worker threads waiting to process jobs. Java 5 introduction of Executor framework has made it very easy to create thread pool in java using Executors and ThreadPoolExecutor classes. Learn how to use them to create thread pool in java.</p>
</li>
<li><h3 id="Java-Callable-Future"><a href="#Java-Callable-Future" class="headerlink" title="Java Callable Future"></a><span id="java-callable-future"><a href="https://www.journaldev.com/1090/java-callable-future-example" target="_blank" rel="noopener" title="Java Callable Future Example">Java Callable Future</a></span></h3><p>Sometimes we wish Thread could return values that we can use. Java 5 Callable can be used in that case that is similar as Runnable interface. We can use Executor framework to execute Callable tasks.</p>
</li>
<li><h3 id="Java-FutureTask-Example"><a href="#Java-FutureTask-Example" class="headerlink" title="Java FutureTask Example"></a><span id="java-futuretask-example"><a href="https://www.journaldev.com/1650/java-futuretask-example-program" target="_blank" rel="noopener" title="Java FutureTask Example">Java FutureTask Example</a></span></h3><p>FutureTask class is the base concrete class that implements Future interface. We use it with Callable implementation and Executors for asynchronous processing. FutureTask provide implementation methods to check the state of the task and return the value to the calling program once it’s processing is finished. It comes handy when you want to override some of the implementation methods of the Future interface.</p>
</li>
</ol>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

  </div>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/3/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/3/">3</a><span class="page-number current">4</span><a class="page-number" href="/page/5/">5</a><span class="space">&hellip;</span><a class="page-number" href="/page/7/">7</a><a class="extend next" rel="next" href="/page/5/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let activeClass = CONFIG.comments.activeClass;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="laudukang"
      src="/images/head.png">
  <p class="site-author-name" itemprop="name">laudukang</p>
  <div class="site-description" itemprop="description">Bug Not Found</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">68</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">10</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">25</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/laudukang" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;laudukang" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://gitee.com/laudukang" title="Gitee → https:&#x2F;&#x2F;gitee.com&#x2F;laudukang" rel="noopener" target="_blank"><i class="fa fa-fw fa-github-alt"></i>Gitee</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://stackoverflow.com/users/5621049/laudukang" title="StackOverflow → https:&#x2F;&#x2F;stackoverflow.com&#x2F;users&#x2F;5621049&#x2F;laudukang" rel="noopener" target="_blank"><i class="fa fa-fw fa-stack-overflow"></i>StackOverflow</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://www.google.com/maps/place/%E6%B7%B1%E5%9C%B3%E5%B8%82%E8%BD%AF%E4%BB%B6%E4%BA%A7%E4%B8%9A%E5%9F%BA%E5%9C%B0/@22.5244896,113.9382973,17z/data=!3m1!4b1!4m5!3m4!1s0x3403ee17d008a019:0xbb7b06b73d856c14!8m2!3d22.5244896!4d113.9382973" title="Map → https:&#x2F;&#x2F;www.google.com&#x2F;maps&#x2F;place&#x2F;%E6%B7%B1%E5%9C%B3%E5%B8%82%E8%BD%AF%E4%BB%B6%E4%BA%A7%E4%B8%9A%E5%9F%BA%E5%9C%B0&#x2F;@22.5244896,113.9382973,17z&#x2F;data&#x3D;!3m1!4b1!4m5!3m4!1s0x3403ee17d008a019:0xbb7b06b73d856c14!8m2!3d22.5244896!4d113.9382973" rel="noopener" target="_blank"><i class="fa fa-fw fa-map-marker"></i>Map</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

<div class="copyright">
  
  &copy; 2015 – 
  <span itemprop="copyrightYear">2025</span>
  <span class="with-love">
    <i class="fa fa-heart icon-next-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">laudukang</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v4.2.0
  </div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> v7.7.1
  </div>

        
<div class="busuanzi-count">
  <script pjax async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
</div>






  <script pjax>
  function leancloudSelector(url) {
    url = encodeURI(url);
    return document.getElementById(url).querySelector('.leancloud-visitors-count');
  }
  if (CONFIG.page.isPost) {
    function addCount(Counter) {
      var visitors = document.querySelector('.leancloud_visitors');
      var url = decodeURI(visitors.getAttribute('id'));
      var title = visitors.getAttribute('data-flag-title');

      Counter('get', `/classes/Counter?where=${JSON.stringify({ url })}`)
        .then(response => response.json())
        .then(({ results }) => {
          if (results.length > 0) {
            var counter = results[0];
              leancloudSelector(url).innerText = counter.time + 1;
            Counter('put', '/classes/Counter/' + counter.objectId, { time: { '__op': 'Increment', 'amount': 1 } })
              .then(response => response.json())
              .catch(error => {
                console.error('Failed to save visitor count', error);
              })
          } else {
              Counter('post', '/classes/Counter', { title: title, url: url, time: 1 })
                .then(response => response.json())
                .then(() => {
                  leancloudSelector(url).innerText = 1;
                })
                .catch(error => {
                  console.error('Failed to create', error);
                });
          }
        })
        .catch(error => {
          console.error('LeanCloud Counter Error', error);
        });
    }
  } else {
    function showTime(Counter) {
      var visitors = document.querySelectorAll('.leancloud_visitors');
      var entries = [...visitors].map(element => {
        return decodeURI(element.getAttribute('id'));
      });

      Counter('get', `/classes/Counter?where=${JSON.stringify({ url: { '$in': entries } })}`)
        .then(response => response.json())
        .then(({ results }) => {
          if (results.length === 0) {
            document.querySelectorAll('.leancloud_visitors .leancloud-visitors-count').forEach(element => {
              element.innerText = 0;
            });
            return;
          }
          for (let item of results) {
            let { url, time } = item;
            leancloudSelector(url).innerText = time;
          }
          for (let url of entries) {
            var element = leancloudSelector(url);
            if (element.innerText == '') {
              element.innerText = 0;
            }
          }
        })
        .catch(error => {
          console.error('LeanCloud Counter Error', error);
        });
    }
  }

  fetch('https://app-router.leancloud.cn/2/route?appId=CPfRDhOlTyfkHW155W3Kx3H1-gzGzoHsz')
    .then(response => response.json())
    .then(({ api_server }) => {
      var Counter = (method, url, data) => {
        return fetch(`https://${api_server}/1.1${url}`, {
          method: method,
          headers: {
            'X-LC-Id': 'CPfRDhOlTyfkHW155W3Kx3H1-gzGzoHsz',
            'X-LC-Key': 'TX05RQSQMd8fbL7RaJNADS7S',
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(data)
        });
      };
      if (CONFIG.page.isPost) {
        if (CONFIG.hostname !== location.hostname) return;
        addCount(Counter);
      } else if (document.querySelectorAll('.post-title-link').length >= 1) {
        showTime(Counter);
      }
    });
  </script>


      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/pjax/pjax.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
  <script src="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>

  <script>
var pjax = new Pjax({
  selectors: [
    'head title',
    '#page-configurations',
    '.content-wrap',
    '.post-toc-wrap',
    '#pjax'
  ],
  switches: {
    '.post-toc-wrap': Pjax.switches.innerHTML
  },
  analytics: false,
  cacheBust: false,
  scrollTo : !CONFIG.bookmark.enable
});

window.addEventListener('pjax:success', () => {
  document.querySelectorAll('script[pjax], script#page-configurations, #pjax script').forEach(element => {
    var code = element.text || element.textContent || element.innerHTML || '';
    var parent = element.parentNode;
    parent.removeChild(element);
    var script = document.createElement('script');
    if (element.id) {
      script.id = element.id;
    }
    if (element.className) {
      script.className = element.className;
    }
    if (element.type) {
      script.type = element.type;
    }
    if (element.src) {
      script.src = element.src;
      // Force synchronous loading of peripheral JS.
      script.async = false;
    }
    if (element.getAttribute('pjax') !== null) {
      script.setAttribute('pjax', '');
    }
    if (code !== '') {
      script.appendChild(document.createTextNode(code));
    }
    parent.appendChild(script);
  });
  NexT.boot.refresh();
  // Define Motion Sequence & Bootstrap Motion.
  if (CONFIG.motion.enable) {
    NexT.motion.integrator
      .init()
      .add(NexT.motion.middleWares.subMenu)
      .add(NexT.motion.middleWares.postList)
      .bootstrap();
  }
  NexT.utils.updateSidebarPosition();
});
</script>




  















    <div id="pjax">
  

  
<script>window.va = window.va || function () { (window.vaq = window.vaq || []).push(arguments); };</script><script defer src="/_vercel/insights/script.js" data-endpoint="/this-is-vercel-insights"></script><script>window.si = window.si || function () { (window.siq = window.siq || []).push(arguments); };</script><script defer src="/_vercel/speed-insights/script.js" data-endpoint="/this-is-vercel-insights-speed"></script>
    </div>
</body>
</html>
